package com.school.controller.user;

import com.school.service.UserService;
import com.school.service.impl.UserServiceImpl;
import com.school.util.ResponseJsonUtil;
import com.school.vo.R;
import com.school.vo.UserRolesVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/getrole")
public class GetRoleController extends HttpServlet {
    UserService userService = new UserServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 1、通过req获取前端提交的用户id
        String userid = req.getParameter("userid");
        Integer userid1 = Integer.valueOf(userid);
        // 2、调用service处结果
        UserRolesVo userRolesVo = userService.getRole(userid1);
        // 3、返回结果
        ResponseJsonUtil.write(resp, R.ok(userRolesVo));
    }
}
